package cn.zhang.controller;


import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.zhang.entity.User;
import cn.zhang.service.UserServiceImpl;

@Controller
public class UserController {

	@Autowired
	private UserServiceImpl userService;

	@RequestMapping("/login")
	public String getUser(HttpServletRequest request, Integer uid) {

		User user = userService.selectByPrimaryKey(uid);
		if (user == null) {
			return "login.jsp";
		}
		request.getSession().setAttribute("loginUser", user);
	
		return "success.jsp";
	}

	/**
	 * 用户列表
	 * @param params 封装pageSize、currPage、查询条件
	 * @return
	 */
	@RequestMapping("/userTableList")
	@ResponseBody
	public List<User> userTableList(Map<String,Object> params) {

		List<User> list = userService.loadAllData(params);
	
		return list;
	}
}
